package com.hky.common.config.freemarker;

import java.util.Calendar;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.view.freemarker.FreeMarkerView;

/**
 * 添加freemarker绝对路径.
 * @author mac
 *
 */
public class MyFreeMarkerView extends FreeMarkerView{
	
	private static final String CONTEXT_PATH = "basePath"; 
	private static final String VERSION = "_v"; 
	/**
	 * 重写该方法生成
	 */
	@Override
	protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request) throws Exception {
		//服务器绝对路径
		model.put(CONTEXT_PATH, request.getContextPath());
		model.put(VERSION, Calendar.getInstance().getTime().toString());
		super.exposeHelpers(model, request);
	}
	
	public static void main(String[] args) {
		String time = Calendar.getInstance().getTime().toString();
		System.out.println(time);
	}
}
